package com.lky.mapper;

import com.lky.domain.Planetype;
import com.lky.domain.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface PlanetypeMapper {

    //查询全部飞机类型
    @Select("select * from plane_type")
    @Results(id = "findAllPlanetype",value = {
            @Result(id = true,column = "id",property = "id"),
            @Result(column = "typename",property = "typename"),
            @Result(column = "typetext",property = "typetext")
    })
    List<Planetype> findAllPlanetype();

    //添加飞机类型
    @Insert("insert into plane_type(typename,typetext) " +
            "values(#{typename},#{typetext})")
    int insertPlanetype(Planetype planetype);

    //根据id查询
    @Select("select * from plane_type where id=#{id}")
    @Results(id = "findPlanetypeById",value = {
            @Result(id=true,column = "id",property = "id"),
            @Result(column = "typename",property = "typename"),
            @Result(column = "typetext",property = "typetext")
    })
    Planetype findPlanetypeById(Integer id);
    //更新信息
    @Update("update plane_type " +
            "set typename=#{typename},typetext=#{typetext}" +
            "where id=#{id}")
    int updatePlanetypeById(Planetype planetype);

    //删除信息
    @Delete("delete from plane_type where id=#{id}")
    int deletePlanetypeById(Integer id);

    //模糊查询
    @Select("select * from plane_type where 1=1 and typename like CONCAT('%',#{searchParam},'%') " +
            "or typetext like CONCAT('%',#{searchParam},'%')")
    @Results(id = "findPlanetypeByStr",value = {
            @Result(id=true,column = "id",property = "id"),
            @Result(column = "typename",property = "typename"),
            @Result(column = "typetext",property = "typetext")
    })
    List<Planetype> findPlanetypeByStr(String str);


}
